package com.weipeep.sys.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.google.common.collect.Lists;
import com.weipeep.sys.vo.ValueTextVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.weipeep.sys.dao.ClassTypeDao;
import com.weipeep.sys.domain.ClassTypeDO;
import com.weipeep.sys.service.ClassTypeService;
import com.weipeep.common.base.CoreServiceImpl;

import javax.annotation.Resource;
import java.util.List;

/**
 * 
 * <pre>
 * 
 * </pre>
 * <small> 2018-04-19 11:59:41 | wangyun</small>
 */
@Service
public class ClassTypeServiceImpl extends CoreServiceImpl<ClassTypeDao, ClassTypeDO> implements ClassTypeService {
    @Resource
    private ClassTypeDao classTypeDao;
    @Override
    public List<ValueTextVo> fetchClassTypes() {
        Wrapper<ClassTypeDO> wrapper = new EntityWrapper<ClassTypeDO>(new ClassTypeDO());
        List<ClassTypeDO> classTypeDOList = classTypeDao.selectList(wrapper);
        List<ValueTextVo> valueTextVoList  = Lists.newArrayList();
        classTypeDOList.stream().forEach(classTypeDO -> {
            ValueTextVo valueTextVo = new ValueTextVo();
            valueTextVo.setValue(classTypeDO.getId());
            valueTextVo.setTitle(classTypeDO.getTitle());
            valueTextVoList.add(valueTextVo);
        });
        return valueTextVoList;
    }
}
